package com.hbsx.why.ui;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hbsx.why.R;
import com.hbsx.why.base.BaseActivity;
import com.hbsx.why.utils.ContextUtils;
import com.hbsx.why.utils.LogUtils;
import com.hbsx.why.utils.SDCardUtils;
import com.hbsx.why.utils.cache.DataCleanManager;
import com.hbsx.why.utils.refresh.PullScrollView;
import com.hbsx.why.utils.refresh.PullToRefreshLayout;

import java.io.File;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by liub on 2017/8/4 14:08.
 */

public class DemoCacheActivity extends BaseActivity {
    @BindView(R.id.tv_topTitle)
    TextView tvTopTitle;
    @BindView(R.id.text_cache)
    TextView textCache;
    @BindView(R.id.cache_size)
    LinearLayout cacheSize;
    @BindView(R.id.img_text_cache)
    TextView imgtextCache;
    @BindView(R.id.img_cache_size)
    LinearLayout imgcacheSize;
    @BindView(R.id.demo_main_scrollview)
    PullScrollView demoMainScrollview;
    @BindView(R.id.pullToRefreshLayout)
    PullToRefreshLayout pullToRefreshLayout;
private Context context=this;
    @Override
    protected int getLayoutResId() {
        return R.layout.demo_cache;
    }

    @Override
    protected void initView() {
        tvTopTitle.setText("缓存相关操作");
        ContextUtils.init(context);
        File file=new File(SDCardUtils.getRootDirectory()+"/updateVersion/");
        try {
            LogUtils.logi("---------file=="+file);
            LogUtils.logi("---------context.getFilesDir()=="+context.getFilesDir());
//            textCache.setText("缓存："+CacheUtils.getInstance(SDCardUtils.getRootDirectory()+"/updateVersion/").getCacheSize());
            textCache.setText("缓存："+DataCleanManager.getCacheSize(context.getCacheDir())+"---"+DataCleanManager.getCacheSize(context.getFilesDir()));
        } catch (Exception e) {
            e.printStackTrace();
        }


    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick({R.id.text_cache, R.id.img_cache_size})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.text_cache:
                toast_short("清除缓存？？？");
                break;
            case R.id.img_cache_size:
                break;
        }
    }
}
